<template>
    <input type="text" :value="currentValue" @input="onInput" @blur="onBlur" />
</template>

<script type="text/javascript">
import Emitter from '@/mixins/emitter.js';
export default {
    mixins: [Emitter],
    props: {
        value: {
            type: String,
            default: ''
        }
    },
    data() {
        return {
            currentValue: this.value
        };
    },
    watch: {
        value(val){
            this.currentValue = val;
        }
    },
    methods: {
        onInput(event){
            const { value } = event.target;
            this.currentValue = value;
            this.$emit('input', value);
            this.dispatch('iFormItem', 'on-form-change', value)
        },
        onBlur(){
            this.dispatch('iFormItem', 'on-form-blur', this.currentValue)
        }
    },
};
</script>

<style lang="less" scoped></style>
